<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/11/22
 * Time: 下午3:19
 */

namespace app\controllers\Project_2_0;


use Core\Controller;
use \app\models\Project_2_0\Student as MStudent;
use Core\MyPDO;

class Student extends Controller
{


    //运行到这里 index.php?action=student&func=index
    function index(){
//        echo "student - index";
        $arr = ["a"=>1,"b"=>2];
        echo json_encode($arr);//接口,基本都是返回的JSON

    }

    //index.php?action=student&func=all
    function all(){

        $stu = new MStudent();
        $res = $stu->all();
        echo json_encode($res);


    }

    function add(){

        $stu_data = [
            "name"=>"八",
            "content"=>"他是一个很有钱的人"
        ];

        $stu_model = new MStudent();
        if($stu_model->save($stu_data) > 0){
            echo "OK";
        }else{
            echo "no ";
        }
    }

}